<?php
//开启会话
session_start();
?>
<?php
include_once 'admin/connect.php';
$time = gmdate("Y-m-d", time() + 8 * 3600);

$sql = "select * from text where adminName = 'admin' ";
$result = mysqli_query($connect, $sql);
if (mysqli_num_rows($result)) {
    $text = mysqli_fetch_array($result);
} else {
    header("Location:admin/login.php");
    die("暂无权限");
}
$id = $_GET['id'];
$article = "SELECT * FROM article WHERE id='$id' limit 1";
$resarticle = mysqli_query($connect, $article);
$info = mysqli_fetch_array($resarticle);
?>
<!DOCTYPE html>
<html>
<head>
    <?php
    include_once 'head.php';
    ?>
    <meta charset="utf-8"/>
    <title><?php echo $text['title'] ?> — <?php echo $text['card1'] ?></title>
    <link rel="stylesheet" href="viewer/css/viewer.min.css">
    <link rel="stylesheet" href="css/little.css">
    <script src="font_leav/iconfont.js"></script>
    <script src="viewer/js/jquery.min.js"></script>
    <script src="viewer/js/viewer-jquery.min.js"></script>
</head>
<body>

<div class="central">
    <div class="title">
<!--        <h1>有人愿意听你碎碎念念也很浪漫</h1>-->
    </div>
    <div class="row central central-800">
            <div class="card col-lg-12 col-md-12 col-sm-12 col-sm-x-12">
                <div class="text">
                        <div class="top-title f2"><?php echo $info['articletitle']?>
                            <svg class="icon" aria-hidden="true">
                                <use xlink:href="#icon-zhankai"></use>
                            </svg>
                        </div>
                    <div class="info">
                    <span>
                        <svg class="icon" aria-hidden="true">
                          <use xlink:href="#icon-shoucang"></use>
                        </svg>
                        <?php echo $info['articlename']?> <i>记录于</i> <?php echo $info['articletime']?></span>
                    </div>
                    <div class="line-top"></div>
                    <div id="md-view" class="file">
                        <?php echo ($info['articletext'])?>

                    </div>
                    <!--<div id="md-cont" class="fileee">-->

                    <!--</div>-->
                     
                     
                     
                    <div class="line">
                        <p>End of content Thank you for watching.</p>
                    </div>
                    
<!-- $str = "This is some <b>bold</b> text.";-->
<!--echo htmlspecialchars($str);-->

                </div>
            </div>
    </div>


</div>
</div>


<!-- footer版权 -->
<div class="footer-warp">
    <div class="footer">
        <p><?php echo $text['icp'] ?></p>
        <p><?php echo $text['Copyright'] ?></p>
    </div>
</div>

<script src="https://cdn.bootcdn.net/ajax/libs/marked/2.0.3/marked.js"></script>

<script>

    let markdown = document.getElementById('md-view');
    let cont = markdown.innerText;
    // console.log(cont);
    markdown.innerHTML = marked(markdown.innerHTML);
    console.log(markdown.innerHTML);
    
        // document.getElementById('md-view').innerHTML =
        // marked.parse(markdown.innerHTML);
        //      console.log(markdown.innerText);
            // marked.parse('# Marked in browser\n\nRendered by **marked**.');
            // var rendererMD = new marked.Renderer();
            // marked.setOptions({
            //     renderer: rendererMD,
            //     gfm: true,
            //     tables: true,
            //     breaks: false,
            //     pedantic: false,
            //     sanitize: false,
            //     smartLists: true,
            //     smartypants: false
            // }); //基本设置
            // var htmlcont = document.getElementById("md-cont");
            // var md = markdown.innerHTML;
            // console.log("获取到的内容:"+md);
            // var cont1 = htmlcont.innerText;
            // console.log(cont1);
            // htmlcont.innerHTML = marked(md);
            // console.log(htmlcont.innerHTML)
</script>



 <!--<script src="https://cdn.staticfile.org/jquery/3.5.1/jquery.min.js"></script> -->
<script src="pagelir/spotlight.bundle.js"></script>
<script>
$(function () {$("img[src$=jpg],img[src$=gif],img[src$=JPG],img[src$=png],img[src$=jpeg]").addClass("spotlight").each(function () {this.onclick = function () {return hs.expand(this)}});})
</script>

</body>
</html>
